#define DEBUG
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn=10000, maxq=100;

class Ques {
public:
  int k, id;

  static bool cmp(Ques a, Ques b) {
    return a.k<b.k;
  }
};

int main() {
  freopen("lottery.in", "r", stdin);
  freopen("lottery.out", "w", stdout);

  static int a[maxn+1], ans[maxq+1][maxn+1], map[maxn+1];
  static Ques que[maxq+2];
  int n, l, q;
  scanf("%d %d", &n, &l);
  for (int i=1; i<=n; i++) {
    scanf("%d", a+i);
  }
  scanf("%d", &q);
  for (int i=1; i<=q; i++) {
    scanf("%d", &que[i].k);
    que[i].id = i;
  }

  sort(que+1, que+q+1, Ques::cmp);
  que[0].k = -1;
  for (int i=1; i<=q; i++) {
    for (int j=que[i-1].k+1; j<=que[i].k; j++) {
      map[j] = que[i].id;
    }
  }

  for (int dis=1; dis<=n-l; dis++) {
    int dif=0;
    for (int i=1; i<=l; i++) {
      dif += a[i]!=a[i+dis];
    }
    ans[map[dif]][1]++;
    ans[map[dif]][1+dis]++;

    for (int i=2; i<=n-l+1-dis; i++) {
      dif += (a[i+l-1]!=a[i+dis+l-1])-(a[i-1]!=a[i-1+dis]);
      ans[map[dif]][i]++;
      ans[map[dif]][i+dis]++;
    }
  }
  for (int i=2; i<=q; i++) {
    for (int j=1; j<=n-l+1; j++) {
      ans[que[i].id][j] += ans[que[i-1].id][j];
    }
  }

  for (int i=1; i<=q; i++) {
    for (int j=1; j<=n-l+1; j++) {
      printf("%d ", ans[i][j]);
    }
    printf("\n");
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
